package com.hg.oa.common;

import android.os.Bundle;
import android.transition.Explode;
import android.transition.Slide;
import android.transition.Transition;
import android.view.Gravity;

import com.baidu.mapapi.SDKInitializer;
import com.baidu.mapapi.map.BaiduMap;
import com.baidu.mapapi.map.MapView;
import com.hg.oa.R;

/**
 * Created by fengxiang on 2016/9/27.
 */
public abstract class BaseMapActivity extends BaseActivityWithToolBar {

    MapView mMapView = null;

    protected BaiduMap baiduMap;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        SDKInitializer.initialize(getApplicationContext());
        setupWindowAnimations();
    }

    private void setupWindowAnimations() {
        Transition transition = buildEnterTransition();
        getWindow().setEnterTransition(transition);
    }

    private Transition buildEnterTransition() {
        //explode 动画方式 从上往下掉的感觉
        //侧边滑出
        Slide enterTransition = new Slide();
        enterTransition.setDuration(getResources().getInteger(R.integer.anim_duration_long));
        enterTransition.setSlideEdge(Gravity.RIGHT);
        return enterTransition;

    }

    @Override
    protected void onBtnLeft1Click() {
        //super.onBtnLeft1Click();
        finishAfterTransition();
    }

    public void setMapView(MapView mMapView) {
        this.mMapView = mMapView;
        baiduMap = mMapView.getMap();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mMapView.onDestroy();
    }

    @Override
    protected void onResume() {
        super.onResume();
        mMapView.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
        mMapView.onPause();
    }
}

